<?php

require_once('functions/pageLoad.php');
require_once('functions/imageScale.php');
loginRequired();
$user_session = explode("_", $_SESSION['user']);
$user_id = $user_session[0];
$page_title = 'Edit company profile';

	$sql = "SELECT id FROM tradesman WHERE user_id = '".$user_id."'";
	$query=mysql_query( $sql ) or die ("Error in query: $sql . " . mysql_error());
	$rs=mysql_fetch_assoc($query);
	$tradesman_id = $rs['id'];

if($_POST['form'] == 'edit-company-profile'){

$fail = '';

$email_regex = "/^[^@]+@([-\w]+\.)+[A-Za-z]{2,4}$/i";
$postcode_regex = "/^([A-PR-UWYZa-pr-uwyz]([0-9]{1,2}|([A-HK-Ya-hk-y][0-9]|[A-HK-Ya-hk-y][0-9]([0-9]|[ABEHMNPRV-Yabehmnprv-y]))|[0-9][A-HJKS-UWa-hjks-uw])\ {0,1}[0-9][ABD-HJLNP-UW-Zabd-hjlnp-uw-z]{2}|([Gg][Ii][Rr]\ 0[Aa][Aa])|([Ss][Aa][Nn]\ {0,1}[Tt][Aa]1)|([Bb][Ff][Pp][Oo]\ {0,1}([Cc]\/[Oo]\ )?[0-9]{1,4})|(([Aa][Ss][Cc][Nn]|[Bb][Bb][Nn][Dd]|[BFSbfs][Ii][Qq][Qq]|[Pp][Cc][Rr][Nn]|[Ss][Tt][Hh][Ll]|[Tt][Dd][Cc][Uu]|[Tt][Kk][Cc][Aa])\ {0,1}1[Zz][Zz]))$/i";

// check email
	$sql = "SELECT id FROM users WHERE email = '".mysql_real_escape_string($_POST['email'])."' AND id != '".$user_id."'";
	$query=mysql_query( $sql ) or die ("Error in query: $sql . " . mysql_error());
	$rows=mysql_num_rows($query);

// check username

	$sql = "SELECT id FROM tradesman WHERE username = '".mysql_real_escape_string($_POST['username'])."' AND user_id != '".$user_id."'";
	$query=mysql_query( $sql ) or die ("Error in query: $sql . " . mysql_error());
	$username_rows=mysql_num_rows($query);

//Change By Vyas Ishan 14 May 2013 Task1
#$fail.= (strlen($_POST['firstname']) == 0 || strlen($_POST['surname']) == 0) ? '<li>Name was not entered</li>' : '';
$fail.= (strlen($_POST['firstname']) == 0 ) ? '<li>Name was not entered</li>' : '';

$fail.= ($username_rows > 0) ? '<li>An account already exists with that username</li>' : '';
$fail.= (strlen($_POST['telephone']) == 0) ? '<li>Telephone number not entered</li>' : '';
$fail.= (strlen($_POST['telephone']) > 0 && !ctype_digit(str_replace(" ", "", $_POST['telephone']))) ? '<li>Invalid telephone number entered, please use numbers only</li>' : '';
$fail.= (strlen($_POST['mobile']) > 0 && !ctype_digit(str_replace(" ", "", $_POST['mobile']))) ? '<li>Invalid mobile number entered, please use numbers only</li>' : '';
$fail.= (preg_match($email_regex, $_POST['email1']) == 0) ? '<li>Invalid email address entered</li>' : '';
//Change By Vyas Ishan 14 May 2013 Task1
#$fail.= ($_POST['email1'] != $_POST['email2']) ? '<li>Email addresses do not match</li>' : '';
$fail.= ($rows > 0) ? '<li>An account already exists with that email address</li>' : '';
$fail.= ((strlen($_POST['password1']) > 0 && strlen($_POST['password1']) < 6) || (strlen($_POST['password1']) > 0 && strlen($_POST['password1']) > 16)) ? '<li>Passwords must be 6-16 characters long</li>' : '';
$fail.= ($_POST['password1'] != $_POST['password2']) ? '<li>Passwords do not match</li>' : '';
$fail.= (strlen($_POST['description']) == 0) ? '<li>Description not entered</li>' : '';
//$fail.= (strlen($_POST['line_1']) == 0) ? '<li>Address was not entered</li>' : '';
//$fail.= (strlen($_POST['city']) == 0) ? '<li>City was not entered</li>' : '';
//$fail.= (preg_match($postcode_regex, str_replace(" ", "", $_POST['postcode'])) == 0) ? '<li>Invalid postcode entered</li>' : '';

if(strlen($fail) > 0){

// PHAIL

$results = '<h1>Update error!</h1><p>Please correct the following errors;</p><ul>'.$fail.'</ul>';

}

else
{

// FINE - UPDATE

	$sql = "SELECT id, description FROM tradesman WHERE user_id = '".$user_id."'";
	$query=mysql_query( $sql ) or die ("Error in query: $sql . " . mysql_error());
	$rs=mysql_fetch_assoc($query);
	$tradesman_id = $rs['id'];

	if(strlen($_POST['password1']) > 0){

	$encrypt1 = base64_encode($_POST['password1'].'_'.$encryption_salt);
	$encrypt2 = md5($encrypt1.'_'.$_POST['email1'].'_'.$encryption_salt);

	$password_update = ", password = '".$encrypt2."'";

	}

	$sql = "SELECT mobile FROM users WHERE id = '".$user_id."'";
	$query=mysql_query( $sql ) or die ("Error in query: $sql . " . mysql_error());
	$rs=mysql_fetch_assoc($query);

	$mobile_verified_change = (str_replace(" ", "", $_POST['mobile']) != $rs['mobile']) ? ", mobile_verified = '0', verification = ''" : '';
	
	// update
		
	//Change By Vyas Ishan 14 May 2013 Task 1
	$surName = '';
	if (array_key_exists('surname',$_POST)) {
		$surName = mysql_real_escape_string(stripslashes($_POST['surname']));
	}	
		
	$sql="UPDATE users SET email = '".mysql_real_escape_string(stripslashes($_POST['email1']))."', firstname = '".mysql_real_escape_string(stripslashes($_POST['firstname']))."', surname = '".$surName."', telephone = '".mysql_real_escape_string(str_replace(" ", "", $_POST['telephone']))."', mobile = '".mysql_real_escape_string(str_replace(" ", "", $_POST['mobile']))."'".$password_update.$mobile_verified_change." WHERE id = '".$user_id."'";
	$query=mysql_query( $sql ) or die ("Error in query: $sql. " . mysql_error());

	// add address?
/*
	$sql = "SELECT line_1, postcode FROM users
		LEFT JOIN addresses ON users.address_id = addresses.id
		WHERE users.id = '".$user_id."'";
	$query=mysql_query( $sql ) or die ("Error in query: $sql . " . mysql_error());
	$rs=mysql_fetch_assoc($query);

	if($_POST['line_1'] != $rs['line_1'] || $_POST['postcode'] != $rs['postcode']){

	// google map

	$address = $_POST['line_1'].",".$_POST['line_2'].",".$_POST['line_3'].",".$_POST['postcode'];
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, "http://maps.google.com/maps/geo?q=".urlencode($address)."&output=csv&oe=utf8&sensor=false&key=".$settings['google_api_key']);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        $output = curl_exec($ch);
        curl_close($ch);
	$outputArr = explode(",",$output);

	$sql="INSERT INTO addresses (user_id, area_id, line_1, line_2, line_3, postcode, longitude, latitude) VALUES ('".$user_id."', '".mysql_real_escape_string($_POST['city'])."', '".mysql_real_escape_string(stripslashes($_POST['line_1']))."', '".mysql_real_escape_string(stripslashes($_POST['line_2']))."', '".mysql_real_escape_string(stripslashes($_POST['line_3']))."', '".mysql_real_escape_string($_POST['postcode'])."', '".$outputArr[3]."', '".$outputArr[2]."')";
	$query=mysql_query( $sql ) or die ("Error in query: $sql. " . mysql_error());
	$address_id = mysql_insert_id();

	// update user

	$userUpdate="UPDATE users SET address_id = '".$address_id."' WHERE id = '".$user_id."'";
	$userResult=mysql_query( $userUpdate ) or die ("Error in query: $userUpdate . " . mysql_error());

	$userUpdate="UPDATE tradesman SET address_id = '".$address_id."' WHERE user_id = '".$user_id."'";
	$userResult=mysql_query( $userUpdate ) or die ("Error in query: $userUpdate . " . mysql_error());
	
	}
	
*/

	// update tradesman

	$sql="UPDATE tradesman SET username = '".mysql_real_escape_string(stripslashes($_POST['username']))."', description = '".mysql_real_escape_string(stripslashes($_POST['description']))."', website = '".mysql_real_escape_string(str_replace("http://", "", $_POST['website']))."' WHERE user_id = '".$user_id."'";
	$query=mysql_query( $sql ) or die ("Error in query: $sql. " . mysql_error());

	// ADMIN EMAIL

	require("classes/class.phpmailer.php");
	$mail2 = new PHPMailer();
	$mail2->IsSMTP(); // telling the class to use SMTP
	$mail2->Host = "localhost"; // SMTP server
	$mail2->From = $settings['no_reply_email'];
	$mail2->FromName = "I Want A Tradesman";

	$mail2->AddAddress($settings['site_email']);

	$mail2->Subject = "Tradesman has updated their profile";
	$mail2->Body = "http://www.iwantatradesman.co.uk/admin/edit_tradesman.php?id=".$tradesman_id;

	$mail2->Send();

	$results = '<p style="color: #009900; font-weight: bold;">Your company profile has been updated successfully!<strong></strong></p>';

}

}

else{

	$sql = "SELECT firstname, surname, username, telephone, mobile, email, company_name, company_type, description, website, line_1, line_2, line_3, area_id, postcode 
	FROM users 
	LEFT JOIN tradesman ON users.id = tradesman.user_id 
	LEFT JOIN addresses ON tradesman.address_id = addresses.id 
	WHERE users.id = '".$user_id."'";
	$query=mysql_query( $sql ) or die ("Error in query: $sql . " . mysql_error());
	$rs=mysql_fetch_assoc($query);

	$_POST['firstname'] = $rs['firstname'];
	
	//Change By Vyas Ishan 14 May 2013 Task1
	#$_POST['surname'] = $rs['surname'];
	
	$_POST['username'] = $rs['username'];
	$_POST['telephone'] = $rs['telephone'];
	$_POST['mobile'] = $rs['mobile'];
	$_POST['email1'] = $rs['email'];
	#$_POST['email2'] = $rs['email'];
	$_POST['company_name'] = $rs['company_name'];
	$_POST['company_type'] = $rs['company_type'];
	$_POST['description'] = $rs['description'];
	$_POST['website'] = $rs['website'];
	$_POST['line_1'] = $rs['line_1'];
	$_POST['line_2'] = $rs['line_2'];
	$_POST['line_3'] = $rs['line_3'];
	$_POST['city'] = $rs['area_id'];
	$_POST['postcode'] = $rs['postcode'];
	$original_email = $rs['email'];

}

// portfolio

$rootPath = $_SERVER['DOCUMENT_ROOT'].'/public_images/';

if($_POST['form'] == 'portfolio'){

// HANDLE IMAGES

	if(isset($_FILES['image_1']['tmp_name']) && strlen($_FILES['image_1']['tmp_name']) > 0){

	$imageName = $_FILES['image_1']['tmp_name'];
	$newImageName = $tradesman_id.'-1-'.mktime();

	//large dimensions
	$maxWidth = '700';
	$maxHeight = '466';
	$imgScale1a = imageScale($rootPath.'large/', $imageName, $newImageName, $maxWidth, $maxHeight);

	//small dimensions
	$maxWidth = '195';
	$maxHeight = '600';
	$imgScale1b = imageScale($rootPath.'small/', $imageName, $newImageName, $maxWidth, $maxHeight);

	if(strlen($imgScale1a['error']) == 0){

	// add image 1 to db

	$sql = "INSERT INTO images (tradesman_id, string) VALUES ('".$tradesman_id."','".$imgScale1a['image']."')";
	$query=mysql_query( $sql ) or die ("Error in query: $sql . " . mysql_error());

	}

	}

	if(isset($_FILES['image_2']['tmp_name']) && strlen($_FILES['image_2']['tmp_name']) > 0){

	$imageName = $_FILES['image_2']['tmp_name'];
	$newImageName = $tradesman_id.'-2-'.mktime();

	//large dimensions
	$maxWidth = '700';
	$maxHeight = '466';
	$imgScale2a = imageScale($rootPath.'large/', $imageName, $newImageName, $maxWidth, $maxHeight);

	//small dimensions
	$maxWidth = '108';
	$maxHeight = '300';
	$imgScale2b = imageScale($rootPath.'small/', $imageName, $newImageName, $maxWidth, $maxHeight);

	if(strlen($imgScale2a['error']) == 0){

	// add image 2 to db

	$sql = "INSERT INTO images (tradesman_id, string) VALUES ('".$tradesman_id."','".$imgScale2a['image']."')";
	$query=mysql_query( $sql ) or die ("Error in query: $sql . " . mysql_error());

	}

	}

	if(isset($_FILES['image_3']['tmp_name']) && strlen($_FILES['image_3']['tmp_name']) > 0){

	$imageName = $_FILES['image_3']['tmp_name'];
	$newImageName = $tradesman_id.'-3-'.mktime();

	//large dimensions
	$maxWidth = '700';
	$maxHeight = '466';
	$imgScale3a = imageScale($rootPath.'large/', $imageName, $newImageName, $maxWidth, $maxHeight);

	//small dimensions
	$maxWidth = '108';
	$maxHeight = '300';
	$imgScale3b = imageScale($rootPath.'small/', $imageName, $newImageName, $maxWidth, $maxHeight);

	if(strlen($imgScale3a['error']) == 0){

	// add image 3 to db

	$sql = "INSERT INTO images (tradesman_id, string) VALUES ('".$tradesman_id."','".$imgScale3a['image']."')";
	$query=mysql_query( $sql ) or die ("Error in query: $sql . " . mysql_error());

	}

	}

	if(isset($_FILES['image_4']['tmp_name']) && strlen($_FILES['image_4']['tmp_name']) > 0){

	$imageName = $_FILES['image_4']['tmp_name'];
	$newImageName = $tradesman_id.'-4-'.mktime();

	//large dimensions
	$maxWidth = '700';
	$maxHeight = '466';
	$imgScale3a = imageScale($rootPath.'large/', $imageName, $newImageName, $maxWidth, $maxHeight);

	//small dimensions
	$maxWidth = '108';
	$maxHeight = '300';
	$imgScale3b = imageScale($rootPath.'small/', $imageName, $newImageName, $maxWidth, $maxHeight);

	if(strlen($imgScale4a['error']) == 0){

	// add image 4 to db

	$sql = "INSERT INTO images (tradesman_id, string) VALUES ('".$tradesman_id."','".$imgScale4a['image']."')";
	$query=mysql_query( $sql ) or die ("Error in query: $sql . " . mysql_error());

	}

	}

	if(isset($_FILES['image_5']['tmp_name']) && strlen($_FILES['image_5']['tmp_name']) > 0){

	$imageName = $_FILES['image_5']['tmp_name'];
	$newImageName = $tradesman_id.'-5-'.mktime();

	//large dimensions
	$maxWidth = '700';
	$maxHeight = '466';
	$imgScale3a = imageScale($rootPath.'large/', $imageName, $newImageName, $maxWidth, $maxHeight);

	//small dimensions
	$maxWidth = '108';
	$maxHeight = '300';
	$imgScale3b = imageScale($rootPath.'small/', $imageName, $newImageName, $maxWidth, $maxHeight);

	if(strlen($imgScale5a['error']) == 0){

	// add image 5 to db

	$sql = "INSERT INTO images (tradesman_id, string) VALUES ('".$tradesman_id."','".$imgScale5a['image']."')";
	$query=mysql_query( $sql ) or die ("Error in query: $sql . " . mysql_error());

	}

	}

$fail.=(strlen($imgScale1a['error']) > 0) ? '<li>Image 1: '.$imgScale1a['error'].'</li>': '';
$fail.=(strlen($imgScale2a['error']) > 0) ? '<li>Image 2: '.$imgScale2a['error'].'</li>': '';
$fail.=(strlen($imgScale3a['error']) > 0) ? '<li>Image 3: '.$imgScale3a['error'].'</li>': '';
$fail.=(strlen($imgScale4a['error']) > 0) ? '<li>Image 4: '.$imgScale4a['error'].'</li>': '';
$fail.=(strlen($imgScale5a['error']) > 0) ? '<li>Image 5: '.$imgScale5a['error'].'</li>': '';

if(strlen($fail) > 0){

$results = '<h1>Update error!</h1><p>We encountered the following errors;</p><ul>'.$fail.'</ul>';

}

}

// logo

if($_POST['form'] == 'logo'){

	if(isset($_FILES['logo']['tmp_name']) && strlen($_FILES['logo']['tmp_name']) > 0){

	$imageName = $_FILES['logo']['tmp_name'];
	$newImageName = $tradesman_id.'-logo-'.mktime();

	$maxWidth = '338';
	$maxHeight = '466';
	$logo = imageScale($rootPath.'logos/', $imageName, $newImageName, $maxWidth, $maxHeight);

	if(strlen($logo['error']) == 0){

	// add logo to db

	$sql = "SELECT logo_id FROM tradesman WHERE id = '".$tradesman_id."'";
	$query=mysql_query( $sql ) or die ("Error in query: $sql . " . mysql_error());
	$rs=mysql_fetch_assoc($query);

	$sql = "DELETE FROM images WHERE id = '".$rs['logo_id']."'";
	$query=mysql_query( $sql ) or die ("Error in query: $sql . " . mysql_error());	

	$sql = "INSERT INTO images (tradesman_id, string) VALUES ('".$tradesman_id."','".$logo['image']."')";
	$query=mysql_query( $sql ) or die ("Error in query: $sql . " . mysql_error());
	$new_logo_id = mysql_insert_id();

	$sql = "UPDATE tradesman SET logo_id = '".$new_logo_id."' WHERE id = '".$tradesman_id."'";
	$query=mysql_query( $sql ) or die ("Error in query: $sql . " . mysql_error());

	}

	}

$fail=(strlen($logo['error']) > 0) ? '<li>Logo: '.$logo['error'].'</li>': '';

if(strlen($fail) > 0){

$results = '<h1>Update error!</h1><p>We encountered the following errors;</p><ul>'.$fail.'</ul>';

}

}

// load logo

$sql = "SELECT logo_id, string FROM tradesman 
	LEFT JOIN images ON tradesman.logo_id = images.id
	WHERE tradesman.user_id = '".$user_id."'";
$query=mysql_query( $sql ) or die ("Error in query: $sql . " . mysql_error());
$logo_rs=mysql_fetch_assoc($query);

if(strlen($logo_rs['string']) > 0){

list($width, $height, $type, $attr) = getimagesize("public_images/logos/".$logo_rs['string']);

$width = ($width > 220) ? ' width="220"' : '' ;

$logo = '<img src="/public_images/logos/'.$logo_rs['string'].'" alt="" style="float: none;"'.$width.' />';

}

// load images

$sql = "SELECT images.id, string FROM images 
	LEFT JOIN tradesman ON images.tradesman_id = tradesman.id
	WHERE tradesman.user_id = '".$user_id."' AND images.id != '".$logo_rs['logo_id']."' LIMIT 0,5";
$query=mysql_query( $sql ) or die ("Error in query: $sql . " . mysql_error());
$image_rows = mysql_num_rows($query);

if($image_rows > 0){
$tradesman_images.='<div id="tradesman_images">';
}

$image_i = 1;

while($image_rs=mysql_fetch_assoc($query)){
$image_class = ($image_i < 5) ? ' class="tradesman_image"' : '' ;
$tradesman_images.='<div style="float: left; text-align: center;"><img src="/public_images/small/'.$image_rs['string'].'" alt=""'.$image_class.' /><br /><a href="/delete_image.php?id='.$image_rs['id'].'"><img src="/images/cross.gif" alt="Delete" style="float: right; position: relative; top: -1px; left: -5px;" title="Delete" /></a></div>';
$image_i++;
}

if($image_rows > 0){
$tradesman_images.='</div>';
}

$image_limit = 5 - $image_rows;

// load areas

	$sql = "SELECT id, area FROM areas ORDER BY area";
	$query=mysql_query( $sql ) or die ("Error in query: $sql . " . mysql_error());

	$areas_dropdown_content = '';

	while($rs=mysql_fetch_assoc($query)){
	$checked = ($_POST['city'] == $rs['id']) ? ' selected="selected"' : '' ;
	$areas_dropdown_content.= '<option value="'.$rs['id'].'"'.$checked.'>'.htmlspecialchars($rs['area']).'</option>'."\r\n";
	}

	$area_dropdown = '<select name="city" id="city" onfocus="return highlight(\'city\');" onblur="return removeHighlight(\'city\');" onchange="return updateMainArea();" class="textbox"><option value="">Please select</option>'.$areas_dropdown_content.'</select>';


include('includes/meta.php');
include('includes/header.php');
include('includes/navigation.php');

?>

<h1><?php echo $page_title; ?></h1>

<?php echo $results; ?>

<div id="error_div" style="display: none;"></div>

<div id="email_change" style="display: none; font-size: 12px;"><span style="color: #cc0000;"><strong>You have changed your email address, please enter your password.</strong></span></div>

<h2>Company logo</h2>

<div id="registration_form">

<form method="post" action="/edit-company-profile" enctype="multipart/form-data">

<input type="hidden" name="form" value="logo" />

<div class="rowWrapper" id="logo_wrap">
<div class="rowLeft"><label for="logo">Company logo:</label><br /><span>(2mb Max)</span></div>
<div class="rowRight">
<div class="image_upload_container"><input type="file" name="logo" id="logo" class="textbox" onfocus="return highlight('logo');" onblur="return removeHighlight('logo');" /></div>
<input type="image" src="/images/update_button.gif" alt="Update" />
</div>
<div class="formRowRight" id="logo_result" style="text-align: center;"><?php echo $logo; ?></div>
</div>

</form>

<div style="float: left; width: 600px;">

<div class="divider"><hr /></div>

<h2>Company portfolio</h2>

<?php echo $tradesman_images; ?>
<div style="clear: both; width: 100%; height: 1px;"></div>
<p style="clear: both; width: 100%;"><strong>Note: You may have a maximum of 5 images for your portfolio.</strong></p>

<?php if($image_limit > 0){ ?>

<form method="post" action="/edit-company-profile" enctype="multipart/form-data">

<input type="hidden" name="form" value="portfolio" />
<input type="hidden" name="total_images" id="total_images" value="1" style="display: none;" />

<div class="rowWrapper" id="image_wrap">
<div class="rowLeft"><label for="image_1">Portfolio images:</label><br /><span>(2mb Max)</span></div>
<div class="rowRight">
<div id="image_uploads">
<div class="image_upload_container"><input type="file" name="image_1" id="image_1" class="textbox" onfocus="return highlight('image');" onblur="return removeHighlight('image');" /></div>
</div>
<?php if($image_limit > 1){ ?>
<div id="addImageLink"><a onclick="return addImageInput2(1,<?php echo $image_limit; ?>);">Add another</a></div>
<?php } ?>
</div>
<div class="formRowRight" id="image_result"></div>
</div>

<div class="rowWrapper">
<div class="rowLeft">&nbsp;</div>
<div class="rowRight"><input type="image" src="/images/update_button.gif" alt="Update" /></div>
</div>

</form>

<?php } ?>

<div class="divider"><hr /></div>

</div>

<h2>Company profile</h2>

<form method="post" action="/edit-company-profile" id="edit-company-profile">

<input type="hidden" name="form" value="edit-company-profile" />

<div id="name_wrap">

<div class="rowWrapper" id="firstname_wrap">
<div class="rowLeft"><label for="firstname">First name:</label></div>
<div class="rowRight"><input type="text" name="firstname" id="firstname" class="textbox" value="<?php echo $_POST['firstname']; ?>" /></div>
</div>

<?php /* //Change By Vyas Ishan 14 May 2013 Task1?>
<div class="rowWrapper" id="surname_wrap">
<div class="rowLeft"><label for="surname">Surname:</label></div>
<div class="rowRight"><input type="text" name="surname" id="surname" class="textbox" value="<?php echo $_POST['surname']; ?>" /></div>
</div>
<?php */?>

</div>

<div id="number_wrap">

<div class="rowWrapper" id="telephone_wrap">
<div class="rowLeft"><label for="telephone">Telephone:</label></div>
<div class="rowRight"><input type="text" name="telephone" id="telephone" class="textbox" value="<?php echo $_POST['telephone']; ?>" /></div>
</div>

<div class="rowWrapper" id="mobile_wrap">
<div class="rowLeft"><label for="mobile">Mobile:</label></div>
<div class="rowRight"><input type="text" name="mobile" id="mobile" class="textbox" value="<?php echo $_POST['mobile']; ?>" /></div>
</div>

</div>

<div id="email_wrap">

<input type="hidden" name="original_email" id="original_email" value="<?php echo $original_email; ?>" />

<div class="rowWrapper" id="email1_wrap">
<div class="rowLeft"><label for="email1">Email address:</label></div>
<div class="rowRight"><input type="text" name="email1" id="email1" class="textbox" value="<?php echo $_POST['email1']; ?>" /></div>
</div>

<?php /*//Change By Vyas Ishan 14 May 2013 Task1?>
<div class="rowWrapper" id="email2_wrap">
<div class="rowLeft"><label for="email2">Confirm email:</label></div>
<div class="rowRight"><input type="text" name="email2" id="email2" class="textbox" value="<?php echo $_POST['email2']; ?>" /></div>
</div>
<?php */?>
</div>

<div id="password_wrap">

<div class="rowWrapper" id="password1_wrap">
<div class="rowLeft"><label for="password1">Password:</label></div>
<div class="rowRight"><input type="password" name="password1" id="password1" class="textbox" /></div>
</div>

<div class="rowWrapper" id="password2_wrap">
<div class="rowLeft"><label for="password2">Confirm password:</label></div>
<div class="rowRight"><input type="password" name="password2" id="password2" class="textbox" /></div>
</div>

</div>

<div id="trade_wrap">

<div class="rowWrapper" id="description_wrap">
<div class="rowLeft"><label for="description">Description:</label></div>
<div class="rowRight"><textarea name="description" id="description" class="textbox" rows="5" cols="30"><?php echo $_POST['description']; ?></textarea></div>
</div>

<div class="rowWrapper" id="website_wrap">
<div class="rowLeft"><label for="website">Website:</label></div>
<div class="rowRight"><input type="text" name="website" id="website" class="textbox" value="<?php echo $_POST['website']; ?>" /></div>
</div>

</div>

<div id="address_wrap" style="display: none;">

<div class="rowWrapper" id="line_1_wrap">
<div class="rowLeft"><label for="line_1">Address line 1:</label></div>
<div class="rowRight"><input type="text" name="line_1" id="line_1" class="textbox" value="<?php echo $_POST['line_1']; ?>" /></div>
</div>

<div class="rowWrapper" id="line_2_wrap">
<div class="rowLeft"><label for="line_2">Address line 2:</label></div>
<div class="rowRight"><input type="text" name="line_2" id="line_2" class="textbox" value="<?php echo $_POST['line_2']; ?>" /></div>
</div>

<div class="rowWrapper" id="line_3_wrap">
<div class="rowLeft"><label for="line_3">Address line 3:</label></div>
<div class="rowRight"><input type="text" name="line_3" id="line_3" class="textbox" value="<?php echo $_POST['line_3']; ?>" /></div>
</div>

<div class="rowWrapper" id="city_wrap">
<div class="rowLeft"><label for="city">Town/City:</label></div>
<div class="rowRight"><?php echo $area_dropdown; ?></div>
</div>

<div class="rowWrapper" id="postcode_wrap">
<div class="rowLeft"><label for="postcode">Postcode:</label></div>
<div class="rowRight"><input type="text" name="postcode" id="postcode" class="textbox" value="<?php echo $_POST['postcode']; ?>" style="width: 80px;" /></div>
</div>

</div>

<div class="rowWrapper">
<div class="rowLeft">&nbsp;</div>
<div class="rowRight"><input type="image" src="/images/update_button.gif" alt="Update" /></div>
</div>

</form>

</div>

<div style="display: none;"><img src="images/tick.png" alt="" /><img src="images/cross.png" alt="" /></div>

<?php 

include('includes/rightColumn.php');
include('includes/footer.php');

?>